package com.fastjars.business.shiro.session;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.CachingSessionDAO;

import java.io.Serializable;

/**
 * ShiroCachingSessionDao
 *
 * @author Brant Liu <br> 邮箱：<br>lbf1988@qq.com <br>日期：<br>2018/06/05
 * @version 1.0.0
 */
public class ShiroCachingSessionDao extends CachingSessionDAO {
    @Override
    protected void doUpdate(Session session) {

    }

    @Override
    protected void doDelete(Session session) {

    }

    @Override
    protected Serializable doCreate(Session session) {
        //不存在才添加。
        if(null == session.getAttribute(SessionManager.DEFAULT_SESSION_STATUS)){
            //Session 踢出自存存储。
            SessionStatus sessionStatus = new SessionStatus();
            session.setAttribute(SessionManager.DEFAULT_SESSION_STATUS, sessionStatus);
        }
        Serializable sessionId = this.generateSessionId(session);
        this.assignSessionId(session, sessionId);
        return sessionId;
    }

    @Override
    protected Session doReadSession(Serializable serializable) {
        return null;
    }
}
